# encoding=utf-8
import re
import matplotlib.pyplot as plt

file = open('consol')
fileContent = file.readlines()
fileLines = []
PredictX = []
PredictY = []
CurrentX = []
CurrentY = []
for i in range(0, len(fileContent)):
    isPredict = True
    line = fileContent[i].split('\n')[0]
    fileLines += [line]
    matchobj = re.match(r'predicted position:\( ?(\d+),(\d+)\)', line)
    if matchobj == None:
        isPredict = False
        matchobj = re.match(r'current position :\( ?(\d+),(\d+)\)', line)
        if matchobj == None:
            continue
    if isPredict:
        PredictX += [matchobj.group(1)]
        PredictY += [matchobj.group(2)]
    else:
        CurrentX += [matchobj.group(1)]
        CurrentY += [matchobj.group(2)]
print len(PredictX)
print len(PredictY)
print len(CurrentX)
print len(CurrentY)
x = range(len(CurrentX))
y = range(len(PredictX))
# plt.plot(x, CurrentX, marker='o', mec='r', mfc='w',label=u'y=x^2曲线图')
plt.plot(y, PredictX)
# plt.legend()  # 让图例生效
# plt.xticks(x, names, rotation=45)
# plt.margins(0)
# plt.subplots_adjust(bottom=0.15)
# plt.xlabel(u"time(s)邻居") #X轴标签
# plt.ylabel("RMSE") #Y轴标签
# plt.title("A simple plot") #标题

plt.show()